package com.unitd.base.frame.plugin.module.dto;

import lombok.*;
import lombok.experimental.Accessors;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 默认的Rest接口反馈数据对象
 *
 * @author Hudan
 * @version 1.0
 * @filename BaseRespDTO.java
 * @copyright www.unitd.com
 * @date 2019-01-23
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
@Accessors(chain = true)
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class BaseRespDTO extends BaseDTO {

    /** 反馈成功响应代码 */
    public final static String SUCCESS = "00000";

    /** 返回码：00000表示成功，其余均表示失败 */
    protected String code;
    /** 返回信息 */
    protected String message;
    /** 响应时间 */
    protected String time;
    /** 响应数据 */
    private Object data;

    public String getTime() {
        if (null == time) {
            SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");
            time = df.format(new Date());
        }
        return time;
    }
}